package com.bluesky.drcp.presentation.web.struts;

import javax.servlet.ServletContext;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionServlet;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.bluesky.drcp.business.logic.DrcpFacade;

public class BaseAction extends Action{
	private DrcpFacade drcp;

	public void setServlet(ActionServlet actionServlet) {
		super.setServlet(actionServlet);
		if (actionServlet != null) {
			ServletContext servletContext = actionServlet.getServletContext();
			WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
			this.drcp = (DrcpFacade) wac.getBean("drcp");
		}
	}

	protected DrcpFacade getDrcp() {
		return drcp;
	}

}
